//
//  XMPointsHeaderView.m
//  XunMi
//
//  Created by MacBook on 2024/3/14.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMPointsHeaderView.h"

@interface XMPointsHeaderView ()
@property (weak, nonatomic) IBOutlet UILabel *zfbLa;
@property (weak, nonatomic) IBOutlet UIImageView *arrowImgV;
@property (weak, nonatomic) IBOutlet UIButton *bindBtn;
@property (weak, nonatomic) IBOutlet UIButton *eyeBtn;
@property (weak, nonatomic) IBOutlet UILabel *useLa;
@property (weak, nonatomic) IBOutlet UILabel *minePointLa;
@property (weak, nonatomic) IBOutlet UILabel *freezePointLa;
@property (weak, nonatomic) IBOutlet UIButton *exchangeBtn;
@property (weak, nonatomic) IBOutlet UIView *bgV;
@property (weak, nonatomic) IBOutlet UILabel *countsLa;

@end

@implementation XMPointsHeaderView

- (void)awakeFromNib {
    [super awakeFromNib];
    kCornerRadius(_bindBtn, 13, 0, UIColor.clearColor);
    kCornerRadius(_exchangeBtn, 18.5, 0, UIColor.clearColor);
    kCornerRadius(_bgV, 14, 0, UIColor.clearColor);
    [_bindBtn.layer addSublayer:[UIColor getGraduallyChangingColor:@[(__bridge id)[UIColor colorWithHexString:@"#FECE59"].CGColor,(__bridge id)[UIColor colorWithHexString:@"#FE883D"].CGColor] locations:@[@0.f, @1.f] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(0, 1) frame:kFRAME(0, 0, 67, 26)]];
    
    [_exchangeBtn.layer addSublayer:[UIColor getGraduallyChangingColor:@[(__bridge id)[UIColor colorWithHexString:@"#FFFFFF"].CGColor,(__bridge id)[UIColor colorWithHexString:@"#FFD1A2"].CGColor] locations:@[@0.f, @1.f] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(0, 1) frame:kFRAME(0, 0, 94, 37)]];
    [_eyeBtn setImagePosition:XMImagePositionRight spacing:7];
}

- (void)setModel:(XMUserModel *)model {
    _model = model;
    if ([XMUtil isBlankString:model.ali_account]) {
        self.bindBtn.hidden = NO;
    } else {
        self.bindBtn.hidden = YES;
        self.zfbLa.text = model.ali_account;
    }
    self.useLa.text = model.handle_score;
    self.minePointLa.text = model.score_number;
    self.freezePointLa.text = model.frozen_score;
    self.countsLa.text = kStringFormat(@"（今日可提现次数%@/%@次）", model.handle_times, model.handle_limit);
}

- (IBAction)afbAct:(id)sender {
    if (self.bindBlock) {
        self.bindBlock();
    }
}

- (IBAction)canUseAct:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        self.useLa.text = @"****";
        self.minePointLa.text = @"****";
        self.freezePointLa.text = @"****";
    } else {
        self.useLa.text = self.model.handle_score;
        self.minePointLa.text = self.model.score_number;
        self.freezePointLa.text = self.model.frozen_score;
    }
}

- (IBAction)exchangeAct:(UIButton *)sender {
    if (self.detailBlock) {
        self.detailBlock();
    }
}
- (IBAction)fro:(id)sender {
    if (self.froBlock) {
        self.froBlock();
    }
}

@end
